package com.heh.mybatisplus.dto;

/**
 * @项目名： spring-emq
 * @包名： com.heh.mybatisplus.dto
 * @文件名: BaseDTO
 * @创建者: liufudong@szyh-smart.com
 * @创建时间: 2024/10/25 17:01
 * @描述：
 */

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.Serializable;

public class BaseDTO implements Serializable {
    private static final long serialVersionUID = 628789637300003134L;

    public String toString() {
        try {
            return (new ObjectMapper()).writeValueAsString(this);
        } catch (JsonProcessingException var2) {
            return JSON.toJSONString(this);
        }
    }

    @JsonIgnore
    @JSONField(
            serialize = false
    )
    public String getJson() {
        return JSONObject.toJSONString(this, new SerializerFeature[]{SerializerFeature.WriteDateUseDateFormat});
    }

    public BaseDTO() {
    }

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof BaseDTO)) {
            return false;
        } else {
            BaseDTO other = (BaseDTO)o;
            return other.canEqual(this);
        }
    }

    protected boolean canEqual(Object other) {
        return other instanceof BaseDTO;
    }

    public int hashCode() {
//        int result = true;
        return 1;
    }
}